package com.vc.aha_server_event.controller;

import com.vc.aha_server_event.entity.Event;
import com.vc.aha_server_event.service.EventService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ShaoZhenbang
 * @description
 * @date 2022/3/30
 */
@RestController
@RequestMapping("/eventManagement")
public class EventManagementController {

    @Resource
    private EventService eventService;

    @GetMapping("/get")
    public Event getEventInfo(@RequestParam Integer eventId) {
        return eventService.getEvent(eventId);
    }

    @DeleteMapping("/delete")
    public Integer deleteEventInfo(@RequestParam Integer eventId) {
        return eventService.deleteEvent(eventId);
    }

    @PostMapping("/insert")
    public Integer insertEventInfo(@RequestBody Event event) {
        return eventService.insertEvent(event);
    }

    @PutMapping("/update")
    public Integer updateEventInfo(@RequestBody Event event) {
        return eventService.updateEvent(event);
    }

    @GetMapping("/getAll")
    public List<Event> getEventInfoPageable(@RequestParam Integer pageNum,
                                            @RequestParam Integer pageSize) {
        return eventService.getAllEvent(pageNum,pageSize);
    }

}
